package com.ruoyi.cat.service.impl;

import java.util.List;
import java.util.concurrent.TimeUnit;

import com.ruoyi.cat.domain.CatBasedataTable;
import com.ruoyi.cat.mapper.CatBasedataTableMapper;
import com.ruoyi.cat.service.ICatBasedataTableService;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * 基础数据设置Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-12-24
 */
@Service
public class CatBasedataTableServiceImpl implements ICatBasedataTableService
{
    @Autowired
    private CatBasedataTableMapper catBasedataTableMapper;

    @Autowired
    private RedisCache redisCache;


    /**
     * 查询基础数据设置
     * 
     * @param id 基础数据设置主键
     * @return 基础数据设置
     */
    @Override
    public CatBasedataTable selectCatBasedataTableById(Long id)
    {
        return catBasedataTableMapper.selectCatBasedataTableById(id);
    }

    @Override
    public CatBasedataTable selectCatBasedataTableByIdRedis(Long id) {
        CatBasedataTable catBasedataTable = redisCache.getCacheObject(CacheConstants.BASEDATA_TABLE);
      //  if (catBasedataTable == null) {
            catBasedataTable = catBasedataTableMapper.selectCatBasedataTableById(id);
            redisCache.setCacheObject(CacheConstants.BASEDATA_TABLE, catBasedataTable,60, TimeUnit.MINUTES);
      //  }
        return catBasedataTable;
    }

    /**
     * 查询基础数据设置列表
     * 
     * @param catBasedataTable 基础数据设置
     * @return 基础数据设置
     */
    @Override
    public List<CatBasedataTable> selectCatBasedataTableList(CatBasedataTable catBasedataTable)
    {
        return catBasedataTableMapper.selectCatBasedataTableList(catBasedataTable);
    }

    /**
     * 新增基础数据设置
     * 
     * @param catBasedataTable 基础数据设置
     * @return 结果
     */
    @Override
    public int insertCatBasedataTable(CatBasedataTable catBasedataTable)
    {
        return catBasedataTableMapper.insertCatBasedataTable(catBasedataTable);
    }

    /**
     * 修改基础数据设置
     * 
     * @param catBasedataTable 基础数据设置
     * @return 结果
     */
    @Override
    public int updateCatBasedataTable(CatBasedataTable catBasedataTable)
    {
        return catBasedataTableMapper.updateCatBasedataTable(catBasedataTable);
    }

    /**
     * 批量删除基础数据设置
     * 
     * @param ids 需要删除的基础数据设置主键
     * @return 结果
     */
    @Override
    public int deleteCatBasedataTableByIds(Long[] ids)
    {
        return catBasedataTableMapper.deleteCatBasedataTableByIds(ids);
    }

    /**
     * 删除基础数据设置信息
     * 
     * @param id 基础数据设置主键
     * @return 结果
     */
    @Override
    public int deleteCatBasedataTableById(Long id)
    {
        return catBasedataTableMapper.deleteCatBasedataTableById(id);
    }
}
